﻿<?php include("conn.php"); ?>
<?php
if($_POST["Type"]=="Edit"){
    $conn=new Mysql();
    $sql="update ads set title='".$_POST["title"]."',title_f='".$_POST["title_f"]."',urls='".$_POST["urls"]."',content='".$_POST["myContent"]."',adpic='".$_POST["adpic"]."' where id=".$_POST["id"];
    if($conn->query($sql)){
        OutErrorBack("修改完成","system-page.php");
    }else{
        OutErrorBack("系统繁忙","system-page.php");
    }

}
?>
<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <?php include("public/cssjs.php");?>
    <link href="lib/webuploader/0.1.5/webuploader.css" rel="stylesheet" type="text/css" />
    <!--/meta 作为公共模版分离出去-->
    <title>基本设置</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span>
    系统管理
    <span class="c-gray en">&gt;</span>
    首页固定广告图
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>

<div class="page-container">
        <section>

                <?php
                $conn=new Mysql();
                $sql = "select * from ads ";
                $page_size = 20;					 //定义每页显示多少记录
                $num_cnt = mysqli_num_rows($conn->query($sql)); //获取总记录数
                $page_cnt = ceil($num_cnt/$page_size);  //计算总页数
                if(isset($_GET["page"])){
                    $page = intval($_GET["page"]);
                }else{
                    $page = 1;
                }
                if ($page<1)
                {
                    $page=1;
                }
                elseif ($page>$page_cnt)
                {
                    $page=$page_cnt;
                }
                $query_start = ($page - 1 ) * $page_size;   //计算每页开始的记录号
                $query_sql = $sql." limit $query_start,$page_size"; //使用limit获取记录

                ?>
                <table class="table table-border table-bordered table-bg">
                    <thead>
                    <tr>
                        <th scope="col" colspan="9">广告图定位</th>
                    </tr>
                    <tr bgcolor="#F3F3F3" class="blueLine">
                        <td width="140">栏目标题</td>
                        <td width="200">内容位置</td>
                        <td width="400" >广告图</td>
                        <td >链接地址</td>
                        <td>操作</td>
                    </tr>
                    </thead>
                    <tbody>

                    <?
                    if($num_cnt>0)
                    {
                        $row=$conn->getAll($query_sql);
                        foreach($row as $key=>$rs){
                            ?>
                            <tr class="text-c">
                                <td><?php echo $rs["title"]; ?></td>
                                <td><?php echo $rs["cssname"]; ?></td>
                                <td>&nbsp;<img src="/pic/<?php echo $rs["adpic"]; ?>" onerror="this.src='/pic/error.jpg'" height="70"></td>
                                <td><?php echo $rs["urls"]; ?></td>

                                <td class="td-manage">
                                    <a style="text-decoration:none" class="ml-5" href="system-ads.php?Type=Edit&id=<?php echo $rs["id"];?>" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> <!--<a style="text-decoration:none" class="ml-5" href="system-page.php?Type=Del&id=<?=$rs["id"]?>" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a>-->

                                </td>
                            </tr>
                            <?
                        }
                        ?>
                        <Tr><Td colspan="9"><?php Controlnews($num_cnt,$page_cnt,$page,'','');?></Td></Tr>

                        <?
                    }else{
                        ?>
                        <Tr><Td colspan="9" align="center">暂无管理员信息</Td></Tr>
                        <?
                    }
                    ?>


                    </tbody>
                </table>


    </section>
    <section>
        <form method="post" action="system-ads.php" name="form1">
            <?
            if(isset($_GET["id"])){$pid=$_GET["id"];}else{$pid=46;}
            $rs=$conn->getRow("select * from ads where id=".$pid);
            if($_GET["id"]!=""){ $typere="Edit";}else{$typere="add";}
            ?>
            <input type="hidden" name="Type" value="<?php echo $typere;?>">
            <table class="table table-bordered">
                <input type="hidden" name="id" value="<?php echo $pid;?>">

                <tr >
                    <td align="right" width="140" >栏目标题：</td>
                    <td ><input name="title"  value="<?php echo $rs["title"];?>"  class="input-text"  type="text" size="100" /></td>
                </tr>
                <tr >
                    <td align="right" width="140" >副标题：</td>
                    <td ><input name="title_f"  value="<?php echo $rs["title_f"];?>"  class="input-text"  type="text" size="100" /></td>
                </tr>
                <tr >
                    <td align="right" >跳转地址：</td>
                    <td ><input name="urls"  value="<?php echo $rs["urls"];?>"   class="input-text" type="text" size="100" /></td>
                </tr>
                <? if($rs["adpic"]!=""){
                    ?>
                    <tr><Td></Td><td><img src="/pic/<?php echo $rs["adpic"];?>" width="200" ></td></tr>
                    <?
                }?>
                <tr >
                    <td align="right" >附图：</td>
                    <td ><iframe
                                src="../pic/images_UP.php?bd=adpic&form=form1" name="key" width="448"
                                height="30" marginheight="0" scrolling="No" frameborder="0" id="key">IE</iframe><input name="adpic"  value="<?php echo $rs["adpic"];?>"   class="input-text" id="adpic" type="text" size="100" /></td>
                </tr>
                <tr>
                    <td colspan="2" align="center" bgcolor="#FFFFFF"><input name="Submit" type="submit" class="btn btn-xs btn-danger" value="　保  存　">　　　</td>
                </tr>

            </table>
        </form>
    </section>

</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/h-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/h-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="lib/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" src="lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    $(function(){
        var ue = UE.getEditor('editor');

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        $("#tab-system").Huitab({
            index:0
        });
        $("#btn-star").click(function(){
            var files=$("#file-2").val();
            $.get("json/upload.php?files="+files,function(data){
                alert(data);
            })
        })
    });
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>
